package com.example.demo03_mvm.view;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;
import android.view.View;

import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.blankj.utilcode.util.GsonUtils;
import com.example.demo03_mvm.R;
import com.example.demo03_mvm.databinding.ActivityDetailBinding;
import com.example.demo03_mvm.viewmodel.DetailViewModel;

import java.util.HashMap;

import io.rong.imkit.RongIM;
import io.rong.imkit.utils.RouteUtils;
import io.rong.imlib.IRongCoreCallback;
import io.rong.imlib.IRongCoreEnum;
import io.rong.imlib.RongCoreClient;
import io.rong.imlib.RongIMClient;
import io.rong.imlib.model.Conversation;

@Route(path = "/app/DetailActivity")
public class DetailActivity extends BaseActivity<DetailViewModel, ActivityDetailBinding> {
    @Autowired
    int id;

    @Override
    protected int inflateLayout() {
        return R.layout.activity_detail;
    }

    @Override
    protected void initData() {
        vm.getDetail(id,db,this);
        db.tvCheckxh.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                vm.onClick(view);
            }
        });
        db.tvAdd.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                vm.addCart(id,DetailActivity.this);
            }
        });

        db.tvKf.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                ARouter.getInstance().build("/app/KFActivity").withInt("gid",id).navigation();
            }
        });
    }

    @Override
    protected void initView() {
        ARouter.getInstance().inject(this);
        db.tool.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();//关闭当前Activity
            }
        });
    }
}